	let that;
	//获取回调数据
	mui.plusReady(function(){
		let pageId = plus.webview
		window.addEventListener('callBackData', function(event) {//A页面自定义事件
			projectVM.tutelageName = event.detail.transForm.tutelageStaffCodeName;
			console.log("回调数据:"+JSON.stringify(event.detail))
			if(projectVM.Record.length <= 0){
				
				projectVM.dataParam = event.detail;
				projectVM.Record = event.detail.infoListParam;
				return
			}
			
			
			if(event.detail.pageType == '0'){
				let data = event.detail.infoListParam;
				// data[0].transOperateId = projectVM.Record[0].transOperateId;
				data.forEach((item,i)=>{
					item.transOperateId = projectVM.Record[0].transOperateId;
				})
				projectVM.Record = projectVM.Record.concat(data)
				
				projectVM.dataParam.transForm.tutelageStaffCodeName = event.detail.transForm.tutelageStaffCodeName
				projectVM.dataParam.transForm.tutelageStaffName = event.detail.transForm.tutelageStaffName
				
				projectVM.dataParam.transOperateId = projectVM.Record[0].transOperateId;
				projectVM.dataParam.infoListParam = projectVM.Record;
			}else{
				let infoListParam =  event.detail.infoListParam[0];
				projectVM.Record.forEach((item,i)=>{
					if(item.transOperateInfoId == infoListParam.transOperateInfoId){
						projectVM.Record.splice(i,1); 
						projectVM.Record.push(infoListParam)
					}
				})
				
				
				projectVM.dataParam.infoListParam = projectVM.Record;
			}
			
			console.log("PPPPPPP:"+JSON.stringify(projectVM.dataParam))
		});	
	})

	projectVM = new Vue({
			el: "#content",
			components:{ 
				personselect
			},
			data: {
				isSingle:false,
				mData:"zq",
				isprocressing:"true",
				Record:[],//操作记录List
				dataParam:"",//全部待提交、保存的数据（从 detail页面携带回来 或者 加载出来的可编辑数据）
				pageParam:"",//页面传值过来的参数
				pageType:"1",////0 录入|新增 1 展示/详情 2编辑修改   （//页面类型 1 办理（带有编辑/详情） 2新增 0 详情（只有详情按钮） 均不可编辑）
				tutelageStaffName:"",//监管人姓名
				tutelageStaffCode:"",//监管人Id
				operateStaffCode:"",//操作人id
				operateStaffName:"",//操作人姓名
				operateName:"",//操作人id+姓名
				tutelageName:"",//监管人id+姓名操作人id+姓名
				isShowTerminalTransfer:false,
				idea:"",//审批意见
				appRovelType:"",//提交类型 0 通过 1 退回
			},
			created() {
				that = this;
				setTimeout(that.getPageParam,500);
			},
			methods:{
				uuidv4() {
					let uuid = mui.neiosCommon.getUuidv4();
					return uuid;
				},
				//获取页面参数（前期没有 plus 环境使用缓存的方式）
				getPageParam(){
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM;
					let paramStr = mui.neioConfig.getStorage(pageKey);
					console.log(paramStr)
					let persionData = JSON.parse(localStorage.getItem("neiosUser"));
					that.operateName = persionData.userName;
					if(undefined != paramStr && "" != paramStr){
						that.pageParam = JSON.parse(paramStr)
						that.pageType = that.pageParam.pageType
						getPageSet().pageTypeSet(that)
					}
				},
				// 显示弹出菜单
				terminalTransfer (appRovelType) {
					that.appRovelType = appRovelType;
					this.isShowTerminalTransfer = true;
				}, 
				//隐藏弹出菜单
				hiddenMenu(){
					this.isShowTerminalTransfer = false;
				},
				//菜单确认按钮
				terminalTransferSure(){
					this.isShowTerminalTransfer = false;
					let appRovelType = that.appRovelType;//提交类型 0 通过 1 退回
					if('0' == appRovelType){
						that.doApproval();
					}
						
					
					if('1' == appRovelType){
						that.sendBack()
					}
				},
				//退回流程
				sendBack(){
					if("" == that.idea){
						mui.alert("请输入审批意见")
						return;
					}
					let persionData = JSON.parse(localStorage.getItem("neiosUser"));
					
					let params = {};
					params.workId = that.pageParam.workId;//任务主键
					params.workType = "0206";//任务类型
					params.workDesc = "对变压器有载调压信息进行修改";//任务描述//分公司编码
					params.nodeDealStaffCode = persionData.userId;//当前登录人id
					params.nodeDealStaffName = persionData.name;// 当前登录人姓名
					params.approveDes = that.idea;//审批意见
					params.nodeDealStaffRole = "1";
					params.forwardNode = "1";
					params.nodeVisibleRange = "20",
					params.userId = persionData.userId;
					params.userName = persionData.name;
					//将主表和子表的状态码 变为32
					that.dataParam.transForm.status = "21";
					that.dataParam.infoListParam.forEach((item,i)=>{
						item.status = "21"
					})
					params.params = that.dataParam;
					let config = mui.neioConfig.getNeioConfig();
					let url = config.URL.sendBackTransOperate;
					console.log(JSON.stringify(params),url)
					mui.neiosRequst.httpRequst(url,params,function(ret){
						if(ret.code == 0){
							mui.toast(ret.msg)
							that.goBack()
						}
						if( ret.code == 1){
							mui.toast(ret.msg)
						}
					},function(err){
						console.log("失败回掉："+JSON.stringify(err))
					})
				},
				/**
				 * 任务审批
				 * @param {Object} appRovelType 0 通过 1 退回
				 */
				doApproval(){
					//人员信息 获取
					if("" == that.idea){
						mui.alert("请输入审批意见")
						return;
					}
					let appRovelType = that.appRovelType;//提交类型 0 通过 1 退回
					let persionData = JSON.parse(localStorage.getItem("neiosUser"));
					let params = {};
					params.workId = that.pageParam.workId;//任务主键
					params.workType = "0206";//任务类型
					params.workDesc = "对变压器有载调压信息进行确认";//任务描述//分公司编码
					params.companyCode = persionData.companyNewCode;//分公司编码
					params.stationCode = localStorage.getItem('neiosStationCode') == null ? '1020' : localStorage.getItem('neiosStationCode');//场站编码
					params.approveDes = that.idea;//审批意见
					params.userId = persionData.userId;
					params.userName = persionData.name;
					//将主表和子表的状态码 变为90
					that.dataParam.transForm.status = "90";
					that.dataParam.infoListParam.forEach((item,i)=>{
						item.status = "90"
					})
					params.params = that.dataParam;
					let config = mui.neioConfig.getNeioConfig();
					let url = config.URL.approveTransOperate;
					console.log(JSON.stringify(params),url)
					mui.neiosRequst.httpRequst(url,params,function(ret){
						if(ret.code == 0){
							mui.toast(ret.msg)
							that.goBack()
						}
						if( ret.code == 1){
							mui.toast(ret.msg)
						}
					},function(err){
						console.log("失败回掉："+JSON.stringify(err))
					})
				},
				//提交操作
				commitData(){
					if("" == that.dataParam){
						mui.toast("请添加记录后提交");
						 return;
					}
					getCommitEntity().commitData(that)
				},
				//保存数据
				saveData(){
					if("" == that.dataParam){
						mui.toast("请添加记录后保存");
						 return;
					}
					getCommitEntity().saveData(that)
				},
				//返回上一页
				goBack(){
					that.doInit();
					setTimeout(mui.back(), 300);
					
				},
				//从新初始化首页数据
				doInit(){
					let pageId = plus.webview.getWebviewById("dailyRecord/transformer/index.html");
					mui.fire(pageId, 'reloadPage', {result:"result"});
				},
				//根据workid 获取
				getDataFromWorkId(url,params){
					mui.neiosRequst.httpRequst(url,params,function(ret){
						console.log(JSON.stringify(ret))
						if(ret.code == 0){
							console.log(ret)
							//列表赋值
							that.Record = ret.data;
							//向列表中设置监护人信息
							that.Record.forEach((item,i)=>{
								item.tutelageStaffCode = that.pageParam.tutelageStaffCode;
								item.tutelageStaffName = that.pageParam.tutelageStaffName;
								item.tutelageStaffCodeName = "[" + that.pageParam.tutelageStaffCode + "]"+that.pageParam.tutelageStaffName;
							})
							that.getTransformerData()
							if(0 < ret.data.length){
								that.tutelageStaffName = ret.tutelageStaffName;
								that.tutelageStaffCode = ret.tutelageStaffCode;
								that.operateStaffCode = ret.operateStaffCode;//操作人id
								that.operateStaffName = ret.operateStaffName;//操作人姓名
								that.operateName = "["+ret.operateStaffCode+"]"+ret.operateStaffName;
								that.tutelageName = "["+ret.tutelageStaffCode+"]"+ret.tutelageStaffName
							}
						}
						if( ret.code == 1){
								mui.toast(ret.msg)
						}
					},function(err){
						console.log("失败回掉："+JSON.stringify(err))
					})
				},
				//根据 transOperateId 获取
				getDataFromtransOperateId(url,params){
					console.log("根据transOperateId 获取:"+JSON.stringify(params))
					mui.neiosRequst.httpRequst(url,params,function(ret){
						console.log(JSON.stringify(ret))
						if(ret.code == 0){
							//列表赋值
							that.Record = ret.data;
							//向列表中设置监护人信息
							that.Record.forEach((item,i)=>{
								item.tutelageStaffCode = that.pageParam.tutelageStaffCode;
								item.tutelageStaffName = that.pageParam.tutelageStaffName;
								item.tutelageStaffCodeName = "[" + that.pageParam.tutelageStaffCode + "]"+that.pageParam.tutelageStaffName;
							})
							that.getTransformerData()
							if(0<ret.data.length){
								that.tutelageStaffName = ret.data[0].tutelageStaffName;
								that.tutelageStaffCode = ret.data[0].tutelageStaffCode;
								that.operateStaffCode = ret.data[0].operateStaffCode;//操作人id
								that.operateStaffName = ret.data[0].operateStaffName;//操作人姓名
								// that.operateName = "["+ret.data[0].operateStaffCode+"]"+ret.data[0].operateStaffName;
								// that.tutelageName = "["+ret.data[0].modifyBy+"]"+ret.data[0].modifyStaffName
							}
						}
						if( ret.code == 1){
								mui.toast(ret.msg)
						}
					},function(err){
						console.log("失败回掉："+JSON.stringify(err))
					})
				},
				//根据获取的数据 编辑成新的完整的数据
				getTransformerData(){
					let jsonData = {};
					if(that.Record.length == 0){
						let datas = {};
						datas.infoListParam = [];
						that.dataParam = datas;	
					}else{
						let datas = mui.neioConfig.getTransForm(that.Record[0],1,0);
						datas.infoListParam = that.Record;
						debugger
						that.dataParam = datas;	
					}

					console.log("KLKLK"+JSON.stringify(that.dataParam))
				},
				getTransFormType(code){
					let transFormTypeList = mui.neioConfig.getTransFormer();
					let type = mui.neiosCommon.dictTransform(JSON.parse(transFormTypeList),code);
					return type;
				},
				//单据编辑
				DocumentsEx(url,position){
					console.log("单据编辑")
					
					that.addDocuments(url,position,'100')
				},
				//删除单据
				DocumentsDelete(item){
					//保存操作
					mui.confirm("是否删除数据",'提示',['取消','确认'],function (e) {
						if(1 == e.index){
							console.log("删除单据"+JSON.stringify(item))
							let data = item;
							data.dataStatus = '0';
							let transFormData = mui.neioConfig.getTransForm(data,0,1)
							let config = mui.neioConfig.getNeioConfig();
							let url = config.URL.saveOrUpdateTransOperate
					
							mui.neiosRequst.httpRequst(url,transFormData,function(ret){
								if(ret.code == 0){
									mui.toast(ret.msg)
									getTransFormList(that);
									that.doInit();
								}
							},function(err){
								mui.toast(ret.msg)
							})
						}
					},'div')
				},
				/**
				 * 跳转到添加列表
				 */
				toAddForm(){
					let url = "detail.html";
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM_TRANSFORM_INFO;
					let param = {}
					param.tutelageStaffCodeName = that.tutelageName;
					param.tutelageStaffCode = that.pageParam.tutelageStaffCode;
					param.mType = "0";//0 录入|新增 1 展示 2编辑修改
					mui.neioConfig.setStorage(pageKey,JSON.stringify(param));
					
					that.gotoPage(url)
				},
				//详情
				showDetal(position){
					//查看详情
					let param = {};
					param.data = that.Record;
					
					param.position = position;//当前选择的第几项
					param.mType = "1";  //0 录入|新增 1 展示/详情 2编辑修改 3办理
					let params = JSON.stringify(param);
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM_TRANSFORM_INFO;
					let paramStr = mui.neioConfig.setStorage(pageKey,params);
					let url = "detail.html";
					that.gotoPage(url)
				},
				//编辑
				editDara(position){
					let param = {};
					//存入人员信息
					that.editPersionData();
					param.position = position;//当前选择的第几项
					param.mType = "2";  //0 录入|新增 1 展示/详情 2编辑修改 3办理
					param.data = that.Record;
					let paramEdt = JSON.stringify(param);
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM_TRANSFORM_INFO;
					mui.neioConfig.setStorage(pageKey,paramEdt);
					let url = "detail.html";
					that.gotoPage(url)
				},
				//编入人员信息
				editPersionData(){
					that.Record.forEach((item,i)=>{
						item.tutelageStaffName = that.pageParam.tutelageStaffName;
						item.tutelageStaffCode = that.pageParam.tutelageStaffCode;
						item.operateStaffCode = that.pageParam.operateStaffCode;
						item.operateStaffName = that.pageParam.operateStaffName;
						item.operateStaffCodeName = that.operateName;
						item.tutelageStaffCodeName = that.tutelageName;
					})
				},
				gotoPage(url){
					mui.openWindow({
						url: url,
						id: url,
						extras: {},
					waiting: {
						autoShow: false
					}
					});
				},
				/**
				 * @param {Object} e
				 * @param {Object} i
				 * @param {Object} type 100 编辑 9 详情 200 添加新的条目（需要传入一个item 为下一个页面获取监护人）
				 */
				addDocuments(e,i,type){
					debugger
					let config = mui.neioConfig.getNeioConfig();
					let pageKey = config.KEYS.PAGE_PARAM_TRANSFORM_INFO;
					
					that.Record.forEach((item,i)=>{
						item.tutelageStaffName = that.pageParam.tutelageStaffName;
						item.tutelageStaffCode = that.pageParam.tutelageStaffCode;
						item.operateStaffCode = that.pageParam.operateStaffCode;
						item.operateStaffName = that.pageParam.operateStaffName;
						item.operateStaffCodeName = that.operateName;
						item.tutelageStaffCodeName = that.tutelageName;
					})
					
					if('100' != type && '200' != type){
						//查看详情
						that.Record.position = i;//当前选择的第几项
						that.Record.pageType = type;
						that.Record.type = type;
						let param = JSON.stringify(that.Record);
						let paramStr = mui.neioConfig.setStorage(pageKey,param);
					}else if('200' == type){
						//新增
						that.Record.pageType = 200;
						that.Record.position = 0;//当前选择的第几项
						that.Record.workId = that.pageParam.workId;
						that.Record.type = 10; //9 不了编辑 10 可编辑 且不显示（空列表）
						let paramCreate = JSON.stringify(that.Record);
						mui.neioConfig.setStorage(pageKey,paramCreate);
					}else{
						that.Record.pageType = '100';
						that.Record.position = i;//当前选择的第几项
						that.Record.workId = that.pageParam.workId;
						that.Record.type = type;
						let paramCreate = JSON.stringify(that.Record);
						mui.neioConfig.setStorage(pageKey,paramCreate);
					}
					
					mui.openWindow({
						url: e,
						id: e,
						extras: {},
					waiting: {
						autoShow: false
					}
					});
				},
				navTo(e){

				},
			}
			})